#include <errno.h>
#include <asm/segment.h>
char iam_name[24]; // Permanent save name
int sys_iam(const char *name)
{
    int i = 0;
    // check length
    while (get_fs_byte(name + i) != '\0')
        i++;
    if (i >= 24)
        return -EINVAL;
    // copy if no error, else do nothing
    for (i = 0; i < 24; i++)
    {
        iam_name[i] = get_fs_byte(name + i);
        if (iam_name[i] == '\0')
            return i;
    }
}

int sys_whoami(char *name, unsigned int size)
{
    // check length
    int i = 0;
    while (iam_name[i] != '\0')
        i++;
    if (i > size) // i<24
        return -EINVAL;
    for (i = 0; i < 24; i++)
    {
        put_fs_byte(iam_name[i], name + i);
        if (iam_name[i] == '\0')
            return i;
    }
}
